package com.jh3502.helper;

import android.content.Context;
import android.support.multidex.MultiDexApplication;

import com.amap.api.location.AMapLocation;
import com.jh3502.helper.base.BaseCrash;
import com.jh3502.helper.net.ApiClient;
import com.jh3502.helper.net.ApiConfiguration;
import com.jh3502.helper.net.ApiConstants;
import com.jh3502.helper.utils.SdCard;
import com.vise.baseble.model.BluetoothLeDevice;

import org.greenrobot.greendao.AbstractDaoMaster;

public class Jh3502HelperApplication extends MultiDexApplication {
    private static final String TAG = "Jh3502HelperApplication";
    private static Context sAppContext;
    private static AMapLocation sMapLocation;
    private BluetoothLeDevice extraDevice;

    public static void initApiClient(int whichService) {
        ApiConfiguration apiConfiguration = ApiConfiguration.builder()
                .dataSourceType(whichService)
                .build();
        ApiClient.init(apiConfiguration);
    }

    public static Context getAppContext() {
        return sAppContext;
    }

    public static AMapLocation getMapLocation() {
        return sMapLocation;
    }

    public static void setMapLocation(AMapLocation mapLocation) {
        sMapLocation = mapLocation;
    }

    public BluetoothLeDevice getExtraDevice() {
        return extraDevice;
    }

    public void setExtraDevice(BluetoothLeDevice device) {
        this.extraDevice = device;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        BaseCrash.getInstance().init(this);
        SdCard.getInstance().mkdirs();
        sAppContext = this.getApplicationContext();
//        initApiClient(ApiConstants.DATA_SOURCE_TYPE_ONLINE);
        initApiClient(ApiConstants.DATA_SOURCE_TYPE_TEST);
//        initApiClient(ApiConstants.DATA_SOURCE_TYPE_DEV);
    }
//    private void initGreenDao() {
//        //DevOpenHelper每次数据库升级会清空数据，一般用于开发
//        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this,"easyMvp_db",null);
//        Database db = helper.getWritableDb();
//        mDaoSession = new DaoMaster(db).newSession();
//    }
//
//    public static DaoSession getDaoSession(){
//        return mDaoSession;
//    }
}
